Page({
  data: {
    point: '', // 小区
    building: '', // *单元/号楼
    rooms: [], // 房间
  },
  // point=瑞光胡同小区&building=4单元
  onLoad({ point, building }) {
    this.fake(point, building)
  },
  fake(point, building) {
    // 房间的数据 4<= room <= 8
    const size = Math.floor(Math.random() * 5) + 4
    const rooms = []

    // 1. 遍历数量
    for (let i = 0; i < size; i++) {
      // 1.1 随机产生楼层(1-20)
      const floor = Math.floor(Math.random() * 20) + 1
      // 1.2 随机产生房间编号(1-4)
      const no = Math.floor(Math.random() * 4) + 1
      // 1.3 组合房间
      const room = [floor, '0', no].join('')
      // 1.5 过滤重复房间
      if (rooms.includes(room)) continue
      // 1.4 把房间放入房间数组
      rooms.push(room)
    }

    // 2. 更新数据
    this.setData({
      rooms,
      building,
      point,
    })
  },
  goForm(e) {
    const { point, building } = this.data
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${point}&building=${building}&room=${e.mark.room}`,
    })
  },
})

// /house_pkg/pages/form/index
// point=恩泽园小区&building=3号楼&room=1301
